home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / gs261sr1.zip / GDEVCDJ.C < prev    next >
C/C++ Source or Header  |  1993-05-20  |  50KB  |  1,526 lines

  1. /* Copyright (C) 1991, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gdevcdj.c */
  20. /* H-P colour printer drivers for Ghostscript */
  21. #include "std.h"                /* to stop stdlib.h redefining types */
  22. #include <stdlib.h>        /* for rand() */
  23. #include "gdevprn.h"
  24. #include "gdevpcl.h"
  25. #include "gsprops.h"
  26.  
  27. /***
  28.  *** Note: this driver was contributed by a user, George Cameron:
  29.  ***       please contact g.cameron@biomed.abdn.ac.uk if you have questions.
  30.  ***/
  31.  
  32. /*
  33.  * Note that there are six drivers contained in this code:
  34.  *
  35.  *     1 - cdj500:      HP DeskJet 500C
  36.  *     2 - cdj550:      HP DeskJet 550C
  37.  *     3 - pjxl300:     HP PaintJet XL300
  38.  *     4 - pj:          HP PaintJet
  39.  *     5 - pjxl:        HP PaintJet XL
  40.  *     6 - declj250:    DEC LJ250
  41.  *
  42.  * All of these drivers have 8-bit (monochrome), 16-bit and 24-bit
  43.  *     (colour) and for the DJ 550C 32-bit, (colour, cmyk mode)
  44.  *     options in addition to the usual 1-bit and 3-bit modes
  45.  * It is also possible to set various printer-specific parameters
  46.  *     from the gs command line, eg.
  47.  *
  48.  *  gs -sDEVICE=cdj550 -dBitsPerPixel=16 -dDepletion=1 -dShingling=2 tiger.ps
  49.  *
  50.  * Please consult the appropriate section in the devices.doc file for
  51.  * further details on all these drivers.
  52.  */
  53.  
  54. #define DESKJET_PRINT_LIMIT  0.04       /* 'real' top margin? */
  55. #define PAINTJET_PRINT_LIMIT 0.0        /* This is a guess.. */
  56.  
  57. /* Margins are left, bottom, right, top. */
  58. #define DESKJET_MARGINS_LETTER   0.25, 0.50, 0.25, 0.167
  59. #define DESKJET_MARGINS_A4       0.125, 0.50, 0.143, 0.167
  60. #define PAINTJET_MARGINS_LETTER  0.167, 0.167, 0.167, 0.167
  61. #define PAINTJET_MARGINS_A4      0.167, 0.167, 0.167, 0.167
  62. #define PAINTJET_MARGINS_A3      0.167, 0.167, 0.167, 0.167
  63.  
  64. /* Default page size is US-Letter or A4 (other sizes from command line) */
  65. #ifndef A4
  66. #  define WIDTH_10THS            85
  67. #  define HEIGHT_10THS           110
  68. #else
  69. #  define WIDTH_10THS            83      /* 210mm */
  70. #  define HEIGHT_10THS           117     /* 297mm */
  71. #endif
  72.  
  73. /* Define bits-per-pixel for generic drivers - default is 24-bit mode */
  74. #ifndef BITSPERPIXEL
  75. #  define BITSPERPIXEL 24
  76. #endif
  77.  
  78. #define W sizeof(word)
  79. #define I sizeof(int)
  80.  
  81. /* Printer types */
  82. #define DJ500C   0
  83. #define DJ550C   1
  84. #define PJXL300  2
  85. #define PJ180    3
  86. #define PJXL180  4
  87. #define DECLJ250 5
  88.  
  89. /* No. of ink jets (used to minimise head movements) */
  90. #define HEAD_ROWS_MONO 50
  91. #define HEAD_ROWS_COLOUR 16
  92.  
  93. /* Colour mapping procedures */
  94. private dev_proc_map_rgb_color (gdev_pcl_map_rgb_color);
  95. private dev_proc_map_color_rgb (gdev_pcl_map_color_rgb);
  96.  
  97. /* Print-page, properties and miscellaneous procedures */
  98. private dev_proc_open_device(dj500c_open);
  99. private dev_proc_open_device(dj550c_open);
  100. private dev_proc_open_device(pjxl300_open);
  101. private dev_proc_open_device(pjxl_open);
  102. private dev_proc_open_device(pj_open);
  103. private dev_proc_print_page(dj500c_print_page);
  104. private dev_proc_print_page(dj550c_print_page);
  105. private dev_proc_print_page(pjxl_print_page);
  106. private dev_proc_print_page(pj_print_page);
  107. private dev_proc_print_page(pjxl300_print_page);
  108. private dev_proc_print_page(declj250_print_page);
  109. private dev_proc_get_props(cdj_get_props);
  110. private dev_proc_get_props(pjxl_get_props);
  111. private dev_proc_get_props(pj_get_props);
  112. private dev_proc_put_props(cdj_put_props);
  113. private dev_proc_put_props(pjxl_put_props);
  114. private dev_proc_put_props(pj_put_props);
  115.  
  116. /* The device descriptors */
  117. typedef struct gx_device_cdj_s gx_device_cdj;
  118. struct gx_device_cdj_s {
  119.         gx_device_common;
  120.         gx_prn_device_common;
  121.     int correction;           /* Black correction parameter */
  122.     int shingling;          /* Interlaced, multi-pass printing */
  123.     int depletion;          /* 'Intelligent' dot-removal */
  124. };
  125.  
  126. typedef struct gx_device_pjxl_s gx_device_pjxl;
  127. struct gx_device_pjxl_s {
  128.         gx_device_common;
  129.         gx_prn_device_common;
  130.     uint correction;          /* Black correction parameter */
  131.     int printqual;            /* Mechanical print quality */
  132.     int rendertype;           /* Driver or printer dithering control */
  133. };
  134.  
  135. typedef struct gx_device_hp_s gx_device_hp;
  136. struct gx_device_hp_s {
  137.         gx_device_common;
  138.         gx_prn_device_common;
  139.     uint correction;          /* Black correction parameter
  140.                    * (used only by DJ500C) */
  141. };
  142.  
  143. typedef struct gx_device_hp_s gx_device_pj;
  144.  
  145. #define hp_device ((gx_device_hp *)pdev)
  146. #define cdj       ((gx_device_cdj *)pdev)
  147. #define pjxl      ((gx_device_pjxl *)pdev)
  148. #define pj    ((gx_device_pj *)pdev)
  149.  
  150. #define prn_hp_colour_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page)\
  151.     prn_device_body(gx_device_printer, procs, dev_name,\
  152.     WIDTH_10THS, HEIGHT_10THS, x_dpi, y_dpi, 0, 0, 0, 0, 0,\
  153.     bpp, 0, 0, 0, 0, print_page)
  154.  
  155. #define cdj_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page, correction, shingling, depletion)\
  156. { prn_hp_colour_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page),\
  157.     correction,\
  158.     shingling,\
  159.     depletion\
  160. }
  161.  
  162. #define pjxl_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page, printqual, rendertype)\
  163. { prn_hp_colour_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page), 0, \
  164.     printqual,\
  165.     rendertype\
  166. }
  167.  
  168. #define pj_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page)\
  169. { prn_hp_colour_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page), 0\
  170. }
  171.  
  172. #define hp_colour_procs(proc_colour_open, proc_get_props, proc_put_props) {\
  173.     proc_colour_open,\
  174.     gdev_pcl_get_initial_matrix,\
  175.     gx_default_sync_output,\
  176.     gdev_prn_output_page,\
  177.     gdev_prn_close,\
  178.     gdev_pcl_map_rgb_color,\
  179.     gdev_pcl_map_color_rgb,\
  180.     NULL,    /* fill_rectangle */\
  181.     NULL,    /* tile_rectangle */\
  182.     NULL,    /* copy_mono */\
  183.     NULL,    /* copy_color */\
  184.     NULL,    /* draw_line */\
  185.     gx_default_get_bits,\
  186.     proc_get_props,\
  187.     proc_put_props\
  188. }
  189.  
  190. private gx_device_procs cdj500_procs =
  191. hp_colour_procs(dj500c_open, cdj_get_props, cdj_put_props);
  192.  
  193. private gx_device_procs cdj550_procs =
  194. hp_colour_procs(dj550c_open, cdj_get_props, cdj_put_props);
  195.  
  196. private gx_device_procs pjxl300_procs =
  197. hp_colour_procs(pjxl300_open, pjxl_get_props, pjxl_put_props);
  198.  
  199. private gx_device_procs pjxl_procs =
  200. hp_colour_procs(pjxl_open, pjxl_get_props, pjxl_put_props);
  201.  
  202. private gx_device_procs pj_procs =
  203. hp_colour_procs(pj_open, pj_get_props, pj_put_props);
  204.  
  205. gx_device_cdj far_data gs_cdjmono_device =
  206. cdj_device(cdj500_procs, "cdjmono", 300, 300, 1,
  207.        dj500c_print_page, 4, 0, 1);
  208.  
  209. gx_device_cdj far_data gs_cdeskjet_device =
  210. cdj_device(cdj500_procs, "cdeskjet", 300, 300, 3,
  211.        dj500c_print_page, 4, 2, 1);
  212.  
  213. gx_device_cdj far_data gs_cdjcolor_device =
  214. cdj_device(cdj500_procs, "cdjcolor", 300, 300, 24,
  215.        dj500c_print_page, 4, 2, 1);
  216.  
  217. gx_device_cdj far_data gs_cdj500_device =
  218. cdj_device(cdj500_procs, "cdj500", 300, 300, BITSPERPIXEL,
  219.        dj500c_print_page, 4, 2, 1);
  220.  
  221. gx_device_cdj far_data gs_cdj550_device =
  222. cdj_device(cdj550_procs, "cdj550", 300, 300, BITSPERPIXEL,
  223.        dj550c_print_page, 0, 2, 1);
  224.  
  225. gx_device_pjxl far_data gs_pjxl300_device =
  226. pjxl_device(pjxl300_procs, "pjxl300", 300, 300, BITSPERPIXEL,
  227.        pjxl300_print_page, 0, 0);
  228.  
  229. gx_device_pjxl far_data gs_pjxl_device =
  230. pjxl_device(pjxl_procs, "pjxl", 180, 180, BITSPERPIXEL,
  231.        pjxl_print_page, 0, 0);
  232.  
  233. gx_device_pj far_data gs